package yygh.hosp.Controller;

import io.swagger.annotations.ApiOperation;
import yygh.hospital.model.hosp.Hospital;
import yygh.hospital.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import yygh.common.result.Result;
import yygh.hosp.Service.HospitalService;

import java.util.List;
import java.util.Map;

/**
 * 主要是实现管理平台医院列表的展示
 */


@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    HospitalService hospitalService;

    //多条件下医院列表查询
    @ApiOperation("多条件下医院列表查询")
    @GetMapping("list/{page}/{limit}")
    public Result list(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo){
       Page<Hospital> hospitalPage= hospitalService.getPage(page,limit,hospitalQueryVo);
        List<Hospital> content = hospitalPage.getContent();
        long totalElements = hospitalPage.getTotalElements();
        return Result.ok(hospitalPage);
    }

    //更新医院的上线状态
    @ApiOperation("更新医院的上线状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id, @PathVariable int status){
        hospitalService.updateHospStatus(id,status);
        return Result.ok();
    }


    //查看医院的详细信息（这边将医院信息封装成一个map集合）
    //根据医院id，获取医院数据
    @ApiOperation("查看医院的详细信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id){
        //这边利用一个map集合来封装我们的医院信息,更加直观。
       Map<Object,Object> map= hospitalService.getHospById(id);
        return  Result.ok(map);
    }



}
